package com.rceeslca.modules.cam.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rceeslca.common.utils.Result;
import com.rceeslca.modules.cam.entity.CamCourseItem;
import com.rceeslca.modules.cam.param.PageQueryParam;
import com.rceeslca.modules.cam.service.CamStudentService;
import com.rceeslca.modules.cam.vo.AttenCourseVo;
import com.rceeslca.modules.cam.vo.CamStudentCourseVo;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 学生
 */
@Api(tags="学生")
@AllArgsConstructor
@RestController
@RequestMapping("/cam/student")
public class CamStudentController {

    @Autowired
    private CamStudentService camStudentService;


    /**
     * 分页查询课程
     * @param param 条件参数
     */
    @PostMapping("pageCourse")
    public Result<IPage<CamStudentCourseVo>> pageCourse(@RequestBody PageQueryParam<CamStudentCourseVo> param) {

        Page<CamStudentCourseVo> page = new Page<>(param.getPageNum(),param.getPageSize());
        IPage<CamStudentCourseVo> iPage = camStudentService.pageCourse(page,param.getQuery());

        return new Result<IPage<CamStudentCourseVo>>().ok(iPage);
    }


    /**
     * 选课
     * @param param 参数
     */
    @PostMapping("choseCourse")
    public Result choseCourse(@RequestBody CamCourseItem param) {

        camStudentService.chooseCourse(param);

        return new Result();
    }


    /**
     * 退课
     * @param courseItem 课程项
     */
    @DeleteMapping("dropCourse")
    public Result dropCourse(@RequestBody CamCourseItem courseItem) {

        camStudentService.dropCourse(courseItem);

        return new Result();
    }


    /**
     * 签到
     * @param param 参数
     */
    @PostMapping("signCourse")
    public Result signInCourse(@RequestBody AttenCourseVo param) {

        camStudentService.signInCourse(param);

        return new Result();
    }


    /**
     * 请假
     * @param param 参数
     */
    @PostMapping("leaveCourse")
    public Result leaveCourse(@RequestBody AttenCourseVo param) {

        camStudentService.leaveCourse(param);

        return new Result();
    }


}
